package com.brzjomo.secretiveworld.world.gen.feature.structure.corpse;

import com.google.common.collect.ImmutableMap;
import com.mojang.datafixers.Dynamic;
import com.mojang.datafixers.types.DynamicOps;

import net.minecraft.world.gen.feature.IFeatureConfig;

public class CorpseOfAnUnknownTravelerConfig implements IFeatureConfig {
	
	public final double probability;
	
	public CorpseOfAnUnknownTravelerConfig(double probability) {
		this.probability = probability;
	}

	@Override
	public <T> Dynamic<T> serialize(DynamicOps<T> ops) {
		return new Dynamic<>(ops, ops.createMap(ImmutableMap.of(ops.createString("probability"), ops.createDouble(this.probability))));
	}
	
	public static <T> CorpseOfAnUnknownTravelerConfig deserialize(Dynamic<T> data) {
		float f = data.get("probability").asFloat(0.0F);
		return new CorpseOfAnUnknownTravelerConfig((double)f);
	}
}
